/* CookieClient.java
 *
 * Author:	Malcolm Staudacher
 * Date:	Oct 22, 2008
 *
 */

package corbacookie.Cookie;

import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;

public class CookieClient {

//	static cookieserver m_cs;
	static cookieserver m_cs;


	public static void main(String args[]) {

		try {
			// create and initialize the ORB
			ORB orb = ORB.init(args, null);

			// get the root naming context
			org.omg.CORBA.Object objRef = orb
					.resolve_initial_references("NameService");
			// Use NamingContextExt instead of NamingContext. This is
			// part of the Interoperable naming Service.
			NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

			// resolve the Object Reference in Naming
			String name = "CookieServer";
//			m_cs = cookieserverHelper.narrow(ncRef.resolve_str(name));
			m_cs = cookieserverHelper.narrow(ncRef.resolve_str(name));

			System.out.println("Obtained a handle on server object: " + m_cs);

			System.out.println(m_cs.printCookie());
			System.out.println(m_cs.printCookieNum(2));
			// m_cs.shutdown();

		} catch (Exception e) {
			System.out.println("ERROR : " + e);
			e.printStackTrace(System.out);
		}
	}


}
